package udes.assassin;

import java.util.List;

import android.graphics.drawable.Drawable;
//import android.location.LocationManager;
import android.os.Bundle;
//import android.telephony.TelephonyManager;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class MyMapActivity extends MapActivity {
	//private TelephonyManager telManager;
	private MapsOverlay itemizedoverlay;
	private List<Overlay> mapOverlays;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.activity_maps);
        
        MapView mapView = (MapView) findViewById(R.id.mymapview);
        mapView.setBuiltInZoomControls(true);
        
        //telManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
        
        itemizedoverlay = new MapsOverlay(this.getResources().getDrawable(R.drawable.person), this);
        mapOverlays = mapView.getOverlays();
        
        // Acquire a reference to the system Location Manager
        //LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

        // Define a listener that responds to location updates
        //MapsLocationListener locationListener = new MapsLocationListener(telManager, this);

        // Register the listener with the Location Manager to receive location updates
        //locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        
        /*SetItemPosition(0, 19240000,-99120000);
        SetItemPosition(0, 45508100, -73555000);
        SetItemPosition(1, 45507000, -73555000);
        SetItemPosition(5451, 45508100, -73556000);*/
        
    }

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
		
	
	public void SetItemPosition(String aName, int latituteE6, int longitudeE6)
	{
		Drawable drawable;
		String displayText;
		
		
		if (aName.equals( Global.getInstance().mId))
		{
			drawable = this.getResources().getDrawable(R.drawable.avatar);
			displayText = "You";
		}
		else if(aName.equals(Global.getInstance().mGame.getPlayer(Global.getInstance().mId).getTargetName()))
		{
			drawable = this.getResources().getDrawable(R.drawable.target);
			displayText = "Target";
		}
		else
		{
			drawable = this.getResources().getDrawable(R.drawable.person);
			displayText = "Player";
		}
		
        GeoPoint point = new GeoPoint(latituteE6, longitudeE6);
        
        OverlayItem overlayitem = new OverlayItem(point, aName, displayText);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        overlayitem.setMarker(drawable);
        itemizedoverlay.addOverlay(aName, overlayitem);
        mapOverlays.add(itemizedoverlay);
	}
}
